package com.xxgc.demo.config;

import org.springframework.stereotype.Component;

@Component
public class DynamicDataSourceContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    /***
     * 设置当前数据源
     */
    public static void setDataSourceName(String name){
        contextHolder.set(name);
    }

    /***
     * 获取当前数据名称
     */
    public static String getDataSourceName(){
        return contextHolder.get();
    }

    /***
     * 清除当前数据名称
     */
    public static void clearDataSourceName(){
        contextHolder.remove();
    }

    public static void push(String source) {
    }
}
